<?php
namespace app\portal\model;

use think\Model;
use think\Db;

class HouseRecord extends Model
{

  protected $name = 'house_records';

  public function addRecord($houseId, $userId, $userName, $typeName) {
    $record = new $this;
    return $record->insert([
      'house_id' => $houseId,
      'user_id' => $userId,
      'user_name' => $userName,
      'type_name' => $typeName,
      'created_at' => date('Y-m-d H:i:s'),
    ]);
  }

  public function user() {
    return $this->hasOne('UserModel', 'id', 'house_id');
  }

}
